package day11.ThreadTest;

import java.util.Arrays;

public class Test5 {
    public static void main(String[] args) {
        char[] a = {'-', '-', '-', '-', '-'};
        new Thread(()->{ // Thread的lambda表达式
            while(true){
                synchronized (a){
                    for (int i = 0; i < a.length; i++) {
                        a[i] = a[i] == '-' ? '*': '-';
                    }
                }

            }
        }).start();
        new Thread(()->{
            while (true){
                synchronized (a){
                    System.out.println(Arrays.toString(a));
                }
            }
        }).start();
    }
}
